package com.NewsServlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet
public class NewsServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        System.out.println("处理请求，doGet被调用！");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        System.out.println("处理请求，doPost被调用！");
    }

    	@Override
    protected void service(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        System.out.println("service派发器作用，根据请求转发到相应的doGet、doPost方法");
        super.service(req, resp);
    }

    @Override
    public void destroy() {
        // TODO Auto-generated method stub
        System.out.println("servlet销毁，destroy被调用！");
    }

    @Override
    public void init(ServletConfig config) throws ServletException {
        // TODO Auto-generated method stub
        System.out.println("servlet初始化，init被调用！");
        String initParam = config.getInitParameter("charSetContent");
        System.out.println("initParam---> " + initParam);
    }

}
